<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\ViewCount;

class GetViewCount extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'zhuanfa:get-view-count';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '获取统计数据';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle(ViewCount $view)
    {
        $this->info("开始执行...");

        if ($view->updateViewCount()) {
            $this->info('浏览量更新成功！');
        } else {
            $this->error('浏览量更新失败！');
        }
    }
}
